package main

import (
	"fmt"
	"time"
)

func main() {
	var (
		closeChan chan int32
	)

	closeChan = make(chan int32)

	go test(closeChan)

	//当管道被关闭或放入值之后，select会执行相应case
	select {
	case v := <-closeChan:
		fmt.Println("关闭", v)
	}
	fmt.Println("结束")
}

func test(closeChan chan int32) {
	time.Sleep(2 * time.Second)
	close(closeChan)
}
